package com.lineng.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.lineng.pojo.Metting;
import com.lineng.service.MettingService;

@Controller
public class MettingController {

	@Autowired
	MettingService mettingService;

	/**
	 * 获取党建会议内容
	 * 
	 * @return
	 */
	@RequestMapping(value = "/getMetting", method = RequestMethod.GET, produces = "text/json;charset=UTF-8")
	@ResponseBody
	public String getMetting() {
		List<Metting> mettings = mettingService.getMetting();
		return JSON.toJSONString(mettings);

	}

	/**
	 * 添加党建会议内容
	 * 
	 * @param metting
	 * @return
	 */
	@RequestMapping(value = "/insertMetting", method = RequestMethod.POST, produces = "text/json;charset=UTF-8")
	@ResponseBody
	public String insertMetting(Metting metting, HttpServletRequest request) {
		return JSON.toJSONString(
				mettingService.insertMetting(metting, (String) request.getSession().getAttribute("username")));

	}

	/**
	 * 更改党建会议内容
	 * 
	 * @param metting
	 * @return
	 */
	@RequestMapping(value = "/updateMetting", method = RequestMethod.POST, produces = "text/json;charset=UTF-8")
	@ResponseBody
	public String updateMetting(Metting metting, HttpServletRequest request) {
		return JSON.toJSONString(
				mettingService.updateMetting(metting, (String) request.getSession().getAttribute("username")));

	}

	/**
	 * 删除党建会议内容
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/deleteMetting", method = RequestMethod.POST, produces = "text/json;charset=UTF-8")
	@ResponseBody
	public String deleteMetting(Integer[] idList) {
		return JSON.toJSONString(mettingService.deleteMetting(idList));

	}
}
